<template lang="html">
  <div class="gifbank_item"  @click="itemClick">
    <div class="gifpack_img">
      <img :src="item.product_image" class="gitbank_item_img"/>
      <div class="img_tag">{{item.rights_title}}</div>
    </div>
    <div class="product_info">
      <div class="product_title">{{item.product_name}}</div>
      <div class="product_tips">{{item.product_tips}}</div>
      <div class="product_tag" v-if="item.rights_title">
        <div class="tag">送</div>
        <div class="tag_txt">{{item.rights_title}}</div>
      </div>
      <div class="price">
        <span>共计：</span><span class="m_price">¥{{item.product_unit_price}}</span>
      </div>
      <div class="button">{{pagetype === 'inve' ? parseFloat(item.discount) ? '分享赚：¥' + item.discount : '分享赚' : '立即开通'}}</div>
    </div>
  </div>
</template>

<script>
export default {
  props: ['item', 'pagetype'],
  data () {
    return {
    }
  },
  created () {
  },
  methods: {
    itemClick () {
      if (this.pagetype === 'inve') {
        let e = this.item
        let url = '/main/giftbagDetails'
        this.$router.push({ path: url,
          query: {
            pid: e.id,
            item_id: e.default_item_id,
            activity_id: e.activity_id ? e.activity_id : 0,
            activity_name: e.activity_name ? e.activity_name : ''
          }
        })
      } else {
        this.goBuy()
      }
    },
    goBuy () {
      this.$toast.loading({
        mask: true,
        message: '加载中...'
      })
      let e = this.item
      let url = '/main/shopDetails'
      this.$router.push({ path: url,
        query: {
          pid: e.id,
          item_id: e.default_item_id,
          activity_id: e.activity_id ? e.activity_id : 0,
          activity_name: e.activity_name ? e.activity_name : ''
        }
      })
      // return new Promise((resolve, reject) => {
      //   this.$Axios({ url: 'check_gift_rule', params: { amount: e.product_unit_price, user_rights_id: e.user_rights_id }, method: 'get' }).then((resp) => { // 请求成功
      //     if (resp.return_code === '0000') {
      //       // this.$toast(resp.data + ',可以购买')
      //       this.$router.push({ path: url,
      //         query: {
      //           pid: e.id,
      //           item_id: e.default_item_id,
      //           activity_id: e.activity_id ? e.activity_id : 0,
      //           activity_name: e.activity_name ? e.activity_name : ''
      //         }
      //       })
      //     } else {
      //       this.$parent.showTips(resp, e)
      //     }
      //     resolve(resp)
      //   }).catch((error) => { // 请求失败
      //     this.$_requestInterceptor('error', error)
      //     reject(error)
      //   })
      // })
    }
  }
}
</script>

<style lang="css" scoped>
</style>
